﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ganosoft.Aspect;
using Ganosoft.Container;

namespace GanoESB.Business.Impl
{
    public class LogInterceptor : IServiceInterceptor
    {
        [Bean]
        protected ILogService logService;

        public object Invoke(IServiceInvocation invocation)
        {
            try
            {
                logService.Info(GetType(), "Entering " + invocation.Method.Name);
                return invocation.InvokeNext();
            }
            catch (Exception ex)
            {
                logService.Fatal(GetType(), ex);
                throw ex;
            }
            finally
            {
                logService.Info(GetType(), "Exit " + invocation.Method.Name);
            }
        }      
    }
}
